package com.ruoyi.project.dict.kangxiwydpage.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.dict.kangxiwydpage.domain.KangxiWydPage;
import com.ruoyi.project.dict.kangxiwydpage.service.IKangxiWydPageService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 武英殿版Controller
 * 
 * @author shixiangwen
 * @date 2022-01-14
 */
@Controller
@RequestMapping("/dict/kangxiwydpage")
public class KangxiWydPageController extends BaseController
{
    private String prefix = "dict/kangxiwydpage";

    @Autowired
    private IKangxiWydPageService kangxiWydPageService;

    @RequiresPermissions("dict:kangxiwydpage:view")
    @GetMapping()
    public String kangxiwydpage()
    {
        return prefix + "/kangxiwydpage";
    }

    /**
     * 查询武英殿版列表
     */
    @RequiresPermissions("dict:kangxiwydpage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(KangxiWydPage kangxiWydPage)
    {
        startPage();
        List<KangxiWydPage> list = kangxiWydPageService.selectKangxiWydPageList(kangxiWydPage);
        return getDataTable(list);
    }

    /**
     * 导出武英殿版列表
     */
    @RequiresPermissions("dict:kangxiwydpage:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(KangxiWydPage kangxiWydPage)
    {
        List<KangxiWydPage> list = kangxiWydPageService.selectKangxiWydPageList(kangxiWydPage);
        ExcelUtil<KangxiWydPage> util = new ExcelUtil<KangxiWydPage>(KangxiWydPage.class);
        return util.exportExcel(list, "kangxiwydpage");
    }

    /**
     * 新增武英殿版
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存武英殿版
     */
    @RequiresPermissions("dict:kangxiwydpage:add")
    @Log(title = "武英殿版", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(KangxiWydPage kangxiWydPage)
    {
        return toAjax(kangxiWydPageService.insertKangxiWydPage(kangxiWydPage));
    }

    /**
     * 修改武英殿版
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        KangxiWydPage kangxiWydPage = kangxiWydPageService.selectKangxiWydPageById(id);
        mmap.put("kangxiWydPage", kangxiWydPage);
        return prefix + "/edit";
    }

    /**
     * 修改保存武英殿版
     */
    @RequiresPermissions("dict:kangxiwydpage:edit")
    @Log(title = "武英殿版", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(KangxiWydPage kangxiWydPage)
    {
        return toAjax(kangxiWydPageService.updateKangxiWydPage(kangxiWydPage));
    }

    /**
     * 删除武英殿版
     */
    @RequiresPermissions("dict:kangxiwydpage:remove")
    @Log(title = "武英殿版", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(kangxiWydPageService.deleteKangxiWydPageByIds(ids));
    }
}
